<?php
/**
 * TestsController.php
 *
 * @copyright   2023 thingsworld.com.cn - All Rights Reserved
 * @link        http://thingsworld.com.cn/
 * @author      stiffer.chen <chenl@thingsworld.com.cn>
 * @created     2023-05-05 17:30:33
 * @modified    2023-05-05 17:30:33
 *
 */

namespace App\Http\Controllers;

use App\Models\User\Cid;
use App\Repositories\NotificationRepo;

class TestsController extends BaseModuleController
{
    public function notify()
    {
        $deviceId = trim(request('device_id', ''));
        if (empty($deviceId)) {
            throw new \Exception('设备ID不能为空');
        }
        $cid = Cid::query()->where('device_id', $deviceId)->first();
        if (empty($cid)) {
            throw new \Exception('设备ID无对应用户信息');
        }
        $userId = $cid->user_id;
        // NotificationRepo::multiStore($userIds, $taskId, NotificationRepo::TYPE_TASK, self::NOTIFY_CREATE['title'], sprintf(self::NOTIFY_CREATE['content'], $task->task_number));
        NotificationRepo::multiStore([$userId], 1, 'task', '测试信息' . rand(100000, 999999), "测试信息正文");
    }

    /**
     * 测试路由信息
     * getPrefix: 路由前缀
     * getName: 路由名称
     *
     * @return void
     */
    public function route()
    {
        dd(request()->route()->getPrefix(), request()->route()->getName(), request()->getMethod());
    }
}